import QtQuick 2.0
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.12

Rectangle {

    id: root

    property string name: ""
    property string type: ""
    property bool isF: true
    property bool isV: true
    property bool isR: false
    property bool isC: true
    property bool isSet: (name!=="") || (type!=="") || isF || isV || isR || isC

    property bool isSelect: false

    // 选中 / 未选中状态 =============================================
    function setSelect(){

        isSelect = true

    }function setUnselect(){

        isSelect = false

    }

    // 内容更新 ======================================================
    function refresh(info){
        name = info["SampleName"]
        type = info["SampleType"]
        isF = info["FAM"].toString() === "1"
        isR = info["ROX"].toString() === "1"
        isV = info["VIC"].toString() === "1"
        isC = info["CY5"].toString() === "1"

    }

    width: 60*dp
    height: 60*dp

    radius: 4*dp

    color: isSelect ? "#F7F9FF" : "white"
    border.color: isSelect ? "#6677FF" : (isSet ? "#CCCCCC" : "transparent")



    MouseArea{
        anchors.fill: parent
        onReleased: {

        }
    }


    Image {
        id: cornerIcon
        height: config.fontsize*2
        width: config.fontsize*2
        source: type==="标准" ? "qrc:/picture/sample_s.png" : (type==="阴性" ? "qrc:/picture/sample_n.png" : (type==="未知" ? "qrc:/picture/sample_u.png" : "qrc:/picture/sample_0.png"))
        visible: isSet

    }

    Text{
        text: name
        font.pixelSize: config.fontsize
        y: root.height/2 - config.fontsize
        height: config.fontsize; width: parent.width
        anchors.horizontalCenter: parent.horizontalCenter
        elide: Text.ElideRight
        horizontalAlignment: Text.AlignHCenter
    }

    Row{
        y: root.height/2 + config.fontsize/2 - 2
        anchors.horizontalCenter: root.horizontalCenter

        height: 22*dp
        width: config.fontsize * ((isF?1:0) + (isC?1:0) + (isV?1:0) + (isR?1:0))
        Item{
            height: 22*dp
            width: config.fontsize
            Text{
                text: "F"
                font.bold: true
                font.pixelSize: config.fontsize + 1
                color: "blue"
                anchors.centerIn: parent

            }
            visible: isF
        }Item{
            height: 22*dp
            width: config.fontsize
            Text{
                text: "V"
                font.bold: true
                font.pixelSize: config.fontsize + 1
                color: "green"
                anchors.centerIn: parent
            }
            visible: isV
        }Item{
            height: 22*dp
            width: config.fontsize
            Text{
                text: "R"
                font.bold: true
                font.pixelSize: config.fontsize + 1
                color: "orange"
                anchors.centerIn: parent
            }
            visible: isR
        }Item{
            height: 22*dp
            width: config.fontsize
            Text{
                text: "C"
                font.bold: true
                font.pixelSize: config.fontsize + 1
                color: "red"
                anchors.centerIn: parent
            }
            visible: isC
        }
    }

    Rectangle{
        id: mask
        radius: 4*dp
        anchors.fill: parent
        color: isSelect ? "#CBCCFA" : "#D2D7FD"
        border.color: isSelect ? "#96A7FF" : "transparent"
        visible: !isSet

    }



}
